package com.android.asportoonline;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;

public class SplashActivity extends Activity{

	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.splash);
		
		/*
		 * Special thanks to: http://www.mubasheralam.com/tutorials/android/how-create-splash-activity-android 
		 */
		
		//Create an object of type SplashHandler
        SplashHandler mHandler = new SplashHandler();
        // Create a Message object
        Message msg = new Message();
        //Assign a unique code to the message.
        //Later, this code will be used to identify the message in Handler class.
        msg.what = 0;
        // Send the message with a delay of 3 seconds(3000 = 3 sec).
        mHandler.sendMessageDelayed(msg, 3000);
	}
	
    // Handler class implementation to handle the message
    private class SplashHandler extends Handler {
        
        //This method is used to handle received messages
        public void handleMessage(Message msg)
          {
            // switch to identify the message by its code
            switch (msg.what)
            {
            default:
            case 0:
              super.handleMessage(msg);
              
              //Create an intent to start the new activity.
              // Our intention is to start MainActivity
              Intent intent = new Intent();
              intent.setClass(SplashActivity.this,ElencoLocalitaActivity.class);
              startActivity(intent);
              // finish the current activity
              SplashActivity.this.finish();
            }
          }
    }  
}
